jQuery(function()
      {
      	 loadLotteryPlay();
      }
	);


function loadLotteryPlay()
{
	 jQuery("#lotteryPaySettingContent").load(base+"/playSetting/queryLotteryPlay.do?lotteryType="+jQuery("#lotteryType").val());
}
     
function updatePlayGroup(playGroupId,status)
{
        var status = getPlayStatus(status);
        jQuery.post(
                      base+"/playSetting/updatePlayGroupStatus.do",
                      {groupId:playGroupId,status:status},
                      function(result){
                             var data=eval("("+result+")");
                             if(data.STATUS==0)
                             {
                                alert("修改成功!");
                                loadLotteryPlay();
                                return ;
                             }
                            alert(data.MSG);  
               });
}


function updatePlay(playId,status,groupId)
{
         var status = getPlayStatus(status);
         jQuery.post(
                      base+"/playSetting/updatePlayStatus.do",
                      {playId:playId,status:status,groupId:groupId},
                      function(result){
                             var data=eval("("+result+")");
                             if(data.STATUS==0)
                             {
                                alert("修改成功!");
                                loadLotteryPlay();
                                return ;
                             }
                            alert(data.MSG);  
               });
}


function updatePlayInfo(playId)
{
     location.href=base+"/playSetting/toEditPlaySetting.do?playId="+playId;
}


function saveLotteryPlayInfo(playId)
{
    var tr = jQuery("#Tr_"+playId);
    var map = new Map();
    map.put("playId",playId);
    map.put("groupId",jQuery(tr).attr("playGroupId"));
    jQuery("input",tr).each(function(index,obj)
          {
                     map.put(jQuery(obj).attr("name"),jQuery(obj).val());
          }
    	); 
      var data =eval("("+map._toJson()+")");
      jQuery.post(
                      base+"/playSetting/updatePlayInfo.do",
                      data,
                      function(result){
                             var data=eval("("+result+")");
                             if(data.STATUS==0)
                             {
                                alert("修改成功!");
                                loadLotteryPlay();
                                return ;
                             }
                            alert(data.MSG);  
               });
}


function savePlayInfo()
{
    jQuery("#playSettingForm").ajaxSubmit(
           {
              type:"post",
              clearForm: true,        // 是否清空form  
              resetForm: true,       // 是否重置form  
              success:function(data)
              { 
                 var d= eval("("+data+")");
                 if(d.STATUS=="0")
                 {
                    alert("修改成功!");
                    location.href=base+"/playSetting.do";
                 }
                 else
                 {
                    alert(d.MSG);
                 }
              }
           }
          );
}

function getPlayStatus(status)
{
   if(status=="Y")
   	   return "N";
   	return "Y";
}